package thread.pipestream;

import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;

/**
 * @author liweimin
 * @date 2021/4/30 17:24
 * @since
 */
public class Test {
    public static void main(String[] args) {

    }

    public static void write(PipedOutputStream out) throws IOException {
        for (int i = 0; i < 100; i++) {
            String data = "" + i;
            out.write(data.getBytes());
        }
        out.close();
    }

    public static void read(PipedInputStream in) throws IOException {
        byte[] bytes = new byte[1024];
        int read = in.read();
        while (read != -1) {
            System.out.println(new String(bytes, 0, read));
            read = in.read(bytes);
        }
        in.close();
    }

}
